package com.peanut.baby.mvp.search;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.QA;

import java.util.List;

/**
 * 排行榜Adapter
 * Created by taransky on 16/5/10.
 */
public class HotListAdapter2 extends BaseAdapter {
    private Context ctx;
    private List<QA> qas;
    private LayoutInflater inflater;


    public HotListAdapter2(Context ctx, List<QA> users) {
        this.ctx = ctx;
        this.qas = users;
        inflater = LayoutInflater.from(ctx);

    }

    @Override
    public int getCount() {
        return qas == null ? 0 : qas.size();
    }

    @Override
    public Object getItem(int position) {
        return qas == null ? null : qas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.layout_item_searchpage_hot, null);
            holder = new ViewHolder();
            holder.label = (TextView) convertView.findViewById(R.id.comment_nick);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.label.setText(qas.get(position).title);
        return convertView;
    }

    class ViewHolder {
        TextView label;
    }
}
